// 创建文件字符输入流
FileReader fr = new FileReader("D:\\文档资料\\电子书\\书籍推荐.txt");

// 使用字符缓冲区
char[] ch = new char[100];
int len = 0;
while ((len = fr.read(ch)) != -1) {
    String s = new String(ch, 0, len);
    System.out.print(s);
}
fr.close();

public class FileInputStreamDemo {
    public static void main(String[] args) {
        try {
            // 创建字节输入流
            FileInputStream is = new FileInputStream("path/to/file");
            int i = 0;

            // 循环读取每个字节直到结束
            while ((i = is.read()) != -1){
                System.out.println((char)i);
            }
            
            // 关闭资源
            is.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
